package com.huaxonline.boot.web.sign;

import lombok.Data;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zhaoshulei
 * @since 2023/9/13
 */
@Data
public class SignInterceptor implements HandlerInterceptor {

    public SignParamFunction<Object> auth = (handler) -> {
    };

    public SignInterceptor(SignParamFunction<Object> auth) {
        this.auth = auth;
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        this.auth.run(handler);
        return true;
    }
}
